import java.util.Arrays;

public class bubbleSort {
    public static void sort(int[] nums){
        if(nums == null || nums.length == 0){
            return;
        }

//        轮次
        for (int round = 1; round <= nums.length; round++) {
//            每轮比较次数
            int compare = nums.length - round;
            for(int i = 0; i < compare; i++){
                if(nums[i] > nums[i+1]){
                    int tmp = nums[i];
                    nums[i] = nums[i+1];
                    nums[i+1] = tmp;
                }
            }
        }
    }

    public static void sort1(int[] nums){

    }

    public static void main1(String[] args){
        int[] nums = {22,31,2,1,5,10};
        sort(nums);
        System.out.println(Arrays.toString(nums));
    }
}
